/*Author: Rony Lahav (ID:043489889)*/

/**
 * Activates the IM command running IMManager
 */
public class CmdIM implements ICmd{

	private String txt;
	
	public CmdIM(String txt){
		this.txt=txt;
	}
	
	//Sends the IM txt message
	public void executeCmd(){
		if (!final_project.isShutDown())
			if (final_project.amIanSN){
				IMManager.getInstance().sendIMToPeers(txt, final_project.getMyPeerID());
				IMManager.getInstance().sendIMToAllSNs(txt, final_project.getMyKey());
			}
			else if (final_project.inFallBackMode)
				IMManager.getInstance().sendIMToPeers(txt, final_project.getMyPeerID());
			else	//regular peer
				IMManager.getInstance().sendIMToSN(txt);
			
	}
}
